import os
from openai import OpenAI

# 加载 .env 到环境变量
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())

# 配置 OpenAI 服务

client = OpenAI(
    # defaults to os.environ.get("OPENAI_API_KEY")
    # api_key=os.getenv("OPENAI_API_KEY"),
    # base_url=os.getenv("OPENAI_BASE_URL")
)

response = client.chat.completions.create(
    messages=[
        {
            "role": "system",
            "content": "你是大语言模型应用开发方面的专家，可以帮助用户解决各种与大模型应用开发相关的问题。并给出相应的解决方案。"
        },
        {
            "role": "user",
            "content": "llama 2的参数？",
        }
    ],
    model="gpt-3.5-turbo",
)

# 循环打印回复
length = len(response.choices)
for i in range(length):
    print(response.choices[i].message.content)
